//
//  BCUserCenterCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/15.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "BCUserCenterCell.h"

#import "BCUserCenterModel.h"

@interface BCUserCenterCell ()

@property (nonatomic, strong) UILabel *customTitleLabel;

/**
 *iconImageView
 */
@property (nonatomic, strong) UIImageView *iconImageView;

/**
 *customAccessoryView
 */
@property (nonatomic, strong) UIImageView *customAccessoryView;

@end

@implementation BCUserCenterCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews {
    self.customTitleLabel = [UILabel new];
    self.customTitleLabel.textColor = [UIColor qmui_colorWithHexString:@"#222222"];
    self.customTitleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
    [self.contentView addSubview:self.customTitleLabel];
    [self.customTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(45.0);
        make.centerY.mas_equalTo(self.contentView);
    }];
    //
    self.iconImageView = [UIImageView new];
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.centerX.mas_equalTo(self.contentView.mas_left).offset(45.0/2);
    }];
    //
    self.customAccessoryView = [UIImageView new];
    self.customAccessoryView.image = LOAD_IMAGE(@"menu_detail_arrow");
    [self.contentView addSubview:self.customAccessoryView];
    [self.customAccessoryView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.right.mas_equalTo(self.contentView).offset(-15.0);
    }];
    //
    [self addSubview:self.separatorLine];
    [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1.0);
        make.centerX.mas_equalTo(self);
        make.bottom.mas_equalTo(self);
        make.width.mas_equalTo(self).offset(-20.0);
    }];
}


- (void)setCenterModel:(BCUserCenterModel *)centerModel {
    _centerModel = centerModel;
    //
    self.iconImageView.image = LOAD_IMAGE(centerModel.iconName);
    //
    NSString *title = centerModel.title;
    if (title) {
        self.customTitleLabel.text = title;
    }else {
        self.customTitleLabel.text = BCLocalizedKey(centerModel.titleKey);
    }
}

@end
